from machine import Pin

from log import Log

log = Log(tag='Status')


class LED:
    def __init__(self, pin=2):
        self.__pin = Pin(pin, Pin.OUT)
        self.status = False
        self.__pin.off()

    def on(self):
        self.__pin.off()
        self.status = True

    def off(self):
        self.__pin.on()
        self.status = False

    def trigger(self):
        if self.status:
            self.off()
        else:
            self.on()


class StatusPin:
    def __init__(self, pin=5):
        self.__pin = Pin(pin, Pin.OUT)
        self.__pin_num = pin
        self.connecting()

    def ready(self):
        self.__pin.value(1)

    def connecting(self):
        self.__pin.value(0)
    
    def as_weakup_hold(self):
        self.__pin = Pin(self.__pin_num, Pin.IN, Pin.PULL_HOLD)
        
    def reset(self):
      self.__pin = Pin(self.__pin_num, Pin.OUT)
      self.connecting()

led = LED()
status_pin = StatusPin()



